package huaweiExam;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Mytest {

    public static void main(String[] args) {

    }

    public static List<Node> getNodes(Node root) {

        List<Node> res = new ArrayList<>();
        if (root == null) {
            return res;
        }
        LinkedList<Node> que = new LinkedList();
        que.add(root);
        while (!que.isEmpty()) {
            Node first = que.removeFirst();
            res.add(first);
            if (first.left != null) {
                que.addLast(first.left);
            }
            if (first.right != null) {
                que.addLast(first.right);
            }
        }

        return res;
    }


    class Node {
        Node left;
        Node right;
    }
}
